<include file="Common/common" />

<body>
	<div class="layui-tab-item layui-show">
		<div class="layui-main">
			<br>
			<div style="overflow-x: auto;">
				<table class="layui-table" id="feedback-list">
					<thead>
							<tr>
								<th>留言编号</th>
								<th>用户</th>
								<th>标题</th>
								<th>留言内容</th>
								<th>留言时间</th>
								<th>系统回复</th>
								<th>操作</th>
							</tr> 
						</thead>
						<tbody>
							<foreach name="feedbackList" item="vo">
								<tr>
									<td>{$vo['id']}</td>
									<td>{$vo['account']}</td>
									<td>{$vo['title']}</td>
									<td>{$vo['content']}</td>
									<td><?php echo date('Y-m-d H:i:s',$vo['createtime']) ?></td>
									<td style="color: red;">{$vo['feedback']}</td>
									<td>
										<if condition="$vo['feedback'] eq '' ">
										 	<button class="layui-btn" onclick="func_reply(this,{$vo['id']},'{$vo['title']}')">回复</button>
										<else/>
											<button class="layui-btn" onclick="func_delete(this,{$vo['id']})">删除留言</button>
									 	</if>

									</td>
								</tr>
							</foreach>
						</tbody>
				</table>
			</div>
			<div class="green-black">{$page}</div>
			
		</div>
	</div>
</body>
<script type="text/javascript">
	// 回复
	function func_reply(obj,id,name){
		layer.open({
			type: 2,
			title: name,
			shadeClose: false,
			closeBtn: 0,
			shade: 0.8,
			scrollbar: false,
			area: ['100%', '100%'],
			content: "/admin.php/News/reply?id="+id, //iframe的url
		 	btn: ['确定', '取消'], //可以无限个按钮
		 	yes: function(index, layero){

            	var content = layero.find("iframe")[0].contentWindow.$("#content").val();

            	layer.confirm('确定保存回复？',{offset:'none'},function(index){
	            	$.ajax({
			            type: "post",
			            url: "{:U('/admin.php/News/ctrl_reply')}",
			            data: {id:id,content:content},
			            dataType: "json",
			            success: function(rtJson){
			            	if (rtJson.code == 1) {
			            		layer.msg(rtJson.msg);
				               	setTimeout(function(){location.reload();}, 1000);
			               	}else{
			               		layer.msg(rtJson.msg);
			               	}
			            }
			        });
			    });
		  	},
		  	btn2: function(index, layero){
			    
			    layer.close(index);
  			}
		});
	}


	function func_delete(obj,id){
		layer.confirm('确定删除留言？',{offset:'none'},function(index){
			$.ajax({
		            type: "post",
		            url: "{:U('/admin.php/News/ctrl_deleteFeedback')}",
		            data: {id:id},
		            dataType: "json",
		            success: function(rtJson){
		            	if (rtJson.code == 1) {
		            		layer.msg(rtJson.msg);
			               	setTimeout(function(){location.reload();}, 1000);
		            	}else{
		            		layer.msg(rtJson.msg);
		            	}
		            	
		            }
			});
		});
	}
</script>
<include file="Common/footer" />